<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //实例化当前日期对象
        var now = new Date();//当期
        var now1 = new Date("2023/5/1");//指定日期

        //通过日期对象获取相关的信息
        var year = now.getFullYear() + "年";
        var month = now.getMonth() + 1 + "月";
        var day = now.getDate() + "日";
        var hours = now.getHours() + "时";
        var minutes = now.getMinutes() + "分";
        var seconds = now.getSeconds() + "秒";

        console.log(year + month + day + hours + minutes + seconds);
        document.write(year + month + day + hours + minutes + seconds);

        //获取当前时间的毫秒数
        //html5方法  兼容性
        console.log(Date.now())

        var a = + new Date();
        console.log(a)

        console.log(now.getTime())
        console.log(now.valueOf())

    </script>
</head>

<body>

</body>

</html>